package com.gjy.stream;

import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.List;
import java.util.TreeSet;
import java.util.stream.Collectors;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-02-06 17:01:09
 */
public class CollectTest {

    private static final List<String> list
            = Arrays.asList("A", "B", "C", "D", "E", "F");

    @Test
    public void test2() {
        list.stream()
                .collect(Collectors.maxBy(String::compareTo))
                .ifPresent(System.out::println);
    }

    @Test
    public void test1() {
        TreeSet<String> collect = list.stream()
                .filter(s -> !s.equals("A"))
                .collect(Collectors.toCollection(TreeSet::new));
        System.out.println("collect = " + collect);
    }
}
